import { Pipe, PipeTransform } from '@angular/core';

/**
 * SN码状态
 * 0：正常 1：已出库 2：冻结
 * ----------------------------------------------------------------
 */
export const sncodeStatusArrs = [
  {value: 0, label: '正常', color: '#67C23A'},
  {value: 1, label: '已出库', color: '#909399'},
  {value: 2, label: '冻结', color: '#F56C6C'}
];

@Pipe({
  name: 'storeSncodeStatus'
})
export class StoreSncodeStatusPipe implements PipeTransform {
  transform(value: any, type: string) {
    let tempObj: any = sncodeStatusArrs.find(item => item.value === value);

    if (type === 'color') {
      return tempObj?.color || '#999999';
    } else {
      return tempObj?.label || '-';
    }
  }
}

/**
 * 商品出入库单据类型
 * 1：入库单 2：出库单 3：调拨单 4：盘点单
 * ----------------------------------------------------------------
 */
 export const billTypeArrs = [
  {value: 1, label: '入库单', color: '#67C23A'},
  {value: 2, label: '出库单', color: '#E6A23C'},
  {value: 3, label: '调拨单', color: '#E6A23C'},
  {value: 4, label: '盘点单', color: '#F56C6C'}
];

@Pipe({
  name: 'storeBillType'
})
export class StoreBillTypePipe implements PipeTransform {
  transform(value: any, type: string) {
    let tempObj: any = billTypeArrs.find(item => item.value === value);

    if (type === 'color') {
      return tempObj?.color || '#999999';
    } else {
      return tempObj?.label || '-';
    }
  }
}

/**
 * 入库单状态
 * 0 草稿 1 待审核 2 审核通过 3 入库中 4 入库完毕 5 已作废
 * ----------------------------------------------------------------
 */
 export const storagePutOrderStateArrs = [
  {value: 0, label: '草稿', color: '#909399'},
  {value: 1, label: '待审核', color: '#E6A23C'},
  {value: 2, label: '审核通过', color: '#67C23A'},
  {value: 3, label: '入库中', color: '#E6A23C'},
  {value: 4, label: '入库完毕', color: '#E6A23C'},
  {value: 5, label: '已作废', color: '#C0C4CC'}
];

@Pipe({
  name: 'storePutStatus'
})
export class StorePutStatusPipe implements PipeTransform {
  transform(value: any, type: string) {
    let tempObj: any = storagePutOrderStateArrs.find(item => item.value === value);

    if (type === 'color') {
      return tempObj?.color || '#999999';
    } else {
      return tempObj?.label || '-';
    }
  }
}

/**
 * 出库单状态
 * 状态 0 草稿 1 待审核 2审核通过 3 待打包 4 待出库 5 已出库 6 已签收 7 已作废 8 已合并
 * ----------------------------------------------------------------
 */
export const storageOutOrderStateArrs = [
  {value: 0, label: '草稿', color: '#909399'},
  {value: 1, label: '待审核', color: '#FF9900'},
  {value: 2, label: '审核通过', color: '#67C23A'},
  {value: 3, label: '待打包', color: '#FF9900'},
  {value: 4, label: '待出库', color: '#FF9900'},
  {value: 5, label: '已出库', color: '#67C23A'},
  {value: 6, label: '已签收', color: '#67C23A'},
  {value: 7, label: '已作废', color: '#909399'},
  {value: 8, label: '已合并', color: '#909399'}
];

@Pipe({
  name: 'storeOutStatus'
})
export class StoreOutStatusPipe implements PipeTransform {
  transform(value: any, type: string) {
    let tempObj: any = storageOutOrderStateArrs.find(item => item.value === value);

    if (type === 'color') {
      return tempObj?.color || '#999999';
    } else {
      return tempObj?.label || '-';
    }
  }
}

/**
 * 调拨单状态
 * 状态(0 草稿 1 待审核 2 审核通过 3 待出库 4 已出库 5 待入库 6 调拨完成 7 已作废)
 * ----------------------------------------------------------------
 */
export const storageAllocationStateArrs = [
  {value: 0, label: '草稿', color: '#606266'},
  {value: 1, label: '待审核', color: '#FF9900'},
  {value: 2, label: '审核通过', color: '#409EFF'},
  {value: 3, label: '待出库', color: '#FF9900'},
  {value: 4, label: '已出库', color: '#FF9900'},
  {value: 5, label: '待入库', color: '#FF9900'},
  {value: 6, label: '调拨完成', color: '#67C23A'},
  {value: 7, label: '已作废', color: '#909399'}
];

@Pipe({
  name: 'storageAllocationState'
})
export class StorageAllocationStatePipe implements PipeTransform {
  transform(value: any, type: string) {
    let tempObj: any = storageAllocationStateArrs.find(item => item.value === value);

    if (type === 'color') {
      return tempObj?.color || '#999999';
    } else {
      return tempObj?.label || '-';
    }
  }
}

/**
 * 采购单状态
 * 状态(0 草稿 1待审核 2进行中 3已结案 4已作废)
 * ----------------------------------------------------------------
 */
export const storagePurchaseStateArrs = [
  {value: 0, label: '草稿', color: '#606266'},
  {value: 1, label: '待审核', color: '#FF9900'},
  {value: 2, label: '进行中', color: '#FF9900'},
  {value: 3, label: '已结案', color: '#67C23A'},
  {value: 4, label: '已作废', color: '#909399'}
];

@Pipe({
  name: 'storagePurchaseState'
})
export class StoragePurchaseStatePipe implements PipeTransform {
  transform(value: any, type: string) {
    let tempObj: any = storagePurchaseStateArrs.find(item => item.value === value);

    if (type === 'color') {
      return tempObj?.color || '#999999';
    } else {
      return tempObj?.label || '-';
    }
  }
}

/**
 * 发货方式 (1物流（自动） 2物流（手动） 3线下配送)
 * ----------------------------------------------------------------
 */
export const storageDeliveryMethodArrs = [
  {value: 1, label: '物流(系统自动下单)', color: '#909399'},
  {value: 2, label: '物流(线下手动下单)', color: '#E6A23C'},
  {value: 3, label: '线下配送', color: '#67C23A'}
];

@Pipe({
  name: 'storageDeliveryMethod'
})
export class StorageDeliveryMethodPipe implements PipeTransform {
  transform(value: any, type: string) {
    let tempObj: any = storageDeliveryMethodArrs.find(item => item.value === value);

    if (type === 'color') {
      return tempObj?.color || '#999999';
    } else {
      return tempObj?.label || '-';
    }
  }
}

/**
 * 行类型
 * 0 指定SN 1 SN管控 2 多库位 3 普通
 * ----------------------------------------------------------------
 */
export const storageLineStateArrs = [
  {value: 0, label: '指定SN', color: '#909399'},
  {value: 1, label: 'SN管控', color: '#E6A23C'},
  {value: 2, label: '多库位', color: '#E6A23C'},
  {value: 3, label: '普通', color: '#67C23A'}
];

@Pipe({
  name: 'storageLineState'
})
export class StorageLineStatePipe implements PipeTransform {
  transform(value: any, type: string) {
    let tempObj: any = storageLineStateArrs.find(item => item.value === value);

    if (type === 'color') {
      return tempObj?.color || '#999999';
    } else {
      return tempObj?.label || '-';
    }
  }
}
